package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TestSysPaper;
import com.ruoyi.system.service.ITestSysPaperService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物料管理Controller
 * 
 * @author ruoyi
 * @date 2025-09-18
 */
@RestController
@RequestMapping("/system/testsyspaper")
public class TestSysPaperController extends BaseController
{
    @Autowired
    private ITestSysPaperService testSysPaperService;

    /**
     * 查询物料管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:testsyspaper:list')")
    @GetMapping("/list")
    public TableDataInfo list(TestSysPaper testSysPaper)
    {
        startPage();
        List<TestSysPaper> list = testSysPaperService.selectTestSysPaperList(testSysPaper);
        return getDataTable(list);
    }

    /**
     * 导出物料管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:testsyspaper:export')")
    @Log(title = "物料管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TestSysPaper testSysPaper)
    {
        List<TestSysPaper> list = testSysPaperService.selectTestSysPaperList(testSysPaper);
        ExcelUtil<TestSysPaper> util = new ExcelUtil<TestSysPaper>(TestSysPaper.class);
        util.exportExcel(response, list, "物料管理数据");
    }

    /**
     * 获取物料管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:testsyspaper:query')")
    @GetMapping(value = "/{paperId}")
    public AjaxResult getInfo(@PathVariable("paperId") Long paperId)
    {
        return success(testSysPaperService.selectTestSysPaperByPaperId(paperId));
    }

    /**
     * 新增物料管理
     */
    @PreAuthorize("@ss.hasPermi('system:testsyspaper:add')")
    @Log(title = "物料管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TestSysPaper testSysPaper)
    {
        return toAjax(testSysPaperService.insertTestSysPaper(testSysPaper));
    }

    /**
     * 修改物料管理
     */
    @PreAuthorize("@ss.hasPermi('system:testsyspaper:edit')")
    @Log(title = "物料管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TestSysPaper testSysPaper)
    {
        return toAjax(testSysPaperService.updateTestSysPaper(testSysPaper));
    }

    /**
     * 删除物料管理
     */
    @PreAuthorize("@ss.hasPermi('system:testsyspaper:remove')")
    @Log(title = "物料管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{paperIds}")
    public AjaxResult remove(@PathVariable Long[] paperIds)
    {
        return toAjax(testSysPaperService.deleteTestSysPaperByPaperIds(paperIds));
    }
}
